#ifndef _MOE_CROSSOVER
#define _MOE_CROSSOVER

#include "engine/Solution.hh"
#include "engine/ArrayList.hh"
#include "engine/Properties.hh"
/**
* This is the Crossover operator, his responsability it's to from a set of mates generate a set of childs
*/
class Crossover {

private:

public:

    Crossover() {}

    virtual ~Crossover() {}

    ArrayList<Solution> *apply(ArrayList<Solution> *mates) {

        ArrayList<Restriction> *restrictions = Solution::getRestrictions();
        ArrayList<Solution> *childs = cross(mates);

        if (restrictions != NULL) {
            for (int i = 0; i < childs->length(); i++)
                for (int j = 0; j < restrictions->length(); j++)
                    restrictions->get(j)->apply(childs->get(i));
        }

        return childs;
    }

    /**
    *@return how many mates expect this operand
    */
    virtual int matesExpected() = 0;


protected:

    /**
    * Make the real cross, it's separated from the apply method, in order to
    * place the restrictions using the template pattern
    * @param mates
    * @return childs
    */
    virtual ArrayList<Solution> *cross(ArrayList<Solution> *mates) = 0;
};
#endif
